//index.js
//获取应用实例
const app = getApp();
var colorName1 = {
  color1: '#bbbbbb'
};
var colorName2 = {
  color2: '#bbbbbb'
};

Page({
  data: {
    items1: [{
      name: 'teacher',
      value: '教师'
    }],
    items2: [{
      name: 'student',
      value: '学生'
    }],
    colorName1,
    colorName2
  },
  onLoad() {
    this.sName = app.globalData.sName
  },
  changeColor1: function (e) {
    this.setData({
      color1: '#6489cd',
      color2: '#bbbbbb'
    })
  },
  changeColor2: function (e) {
    this.setData({
      color2: '#6489cd',
      color1: '#bbbbbb'
    })
  },
  logout() {
    app.globalData.sId = null;
    app.globalData.sName = "登录";

    if (app.globalData.socket) {
      console.log('emit logout')
      app.globalData.socket.emit("logout")
      app.globalData.socket = null;
    }
    wx.showToast({
      title: '注销成功',
      icon: 'success',
      duration: 2000
    })

    wx.navigateBack({
      delta: 1
    })
  },
  updateClass() {
    wx.showLoading({
      title: '正在更新',
    })

    setTimeout(function () {
      wx.hideLoading()
      wx.showToast({
        title: '更新完成',
        icon: 'success',
        duration: 2000
      })
    }, 2000)

  },
  clearStorageSync() {
    try {
      wx.clearStorageSync()
      wx.showLoading({
        title: '正在清理',
      })
      setTimeout(function () {
        wx.hideLoading()
        wx.showToast({
          title: '清理完成',
          icon: 'success',
          duration: 2000
        })
      }, 2000)
    } catch (e) {
      wx.showToast({
        title: '已没有可清理的缓存哦',
        icon: 'error',
        duration: 2000
      })
    }
  }

})